package com.store.satring.web;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.core.convert.converter.Converter;
import org.springframework.format.FormatterRegistry;
import org.springframework.format.support.FormattingConversionServiceFactoryBean;

import com.store.satring.dos.ApplicationAdmin;
import com.store.satring.dos.Customer;
import com.store.satring.dos.GLReport;
import com.store.satring.dos.GeneralLedger;
import com.store.satring.dos.GeneralLedgerDetail;
import com.store.satring.dos.Invoice;
import com.store.satring.dos.Item;
import com.store.satring.dos.ItemBalanceDetail;
import com.store.satring.dos.ItemDetail;
import com.store.satring.dos.ItemReport;
import com.store.satring.dos.ItemReturnDetail;
import com.store.satring.dos.ItemType;
import com.store.satring.dos.aa.Authorities;
import com.store.satring.dos.aa.GroupAuthorities;
import com.store.satring.dos.aa.GroupMembers;
import com.store.satring.dos.aa.Groups;
import com.store.satring.dos.aa.Users;

@Configurable
/**
 * A central place to register application converters and formatters. 
 */
public class ApplicationConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean {

	@Override
	protected void installFormatters(FormatterRegistry registry) {
		super.installFormatters(registry);
		// Register application converters and formatters
	}

	public Converter<Authorities, String> getAuthoritiesToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.store.satring.dos.aa.Authorities, java.lang.String>() {
            public String convert(Authorities authorities) {
                return new StringBuilder().append(authorities.getUsername()).append(' ').append(authorities.getAuthority()).toString();
            }
        };
    }

	public Converter<ApplicationAdmin, String> getApplicationAdminToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.store.satring.dos.ApplicationAdmin, java.lang.String>() {
            public String convert(ApplicationAdmin applicationAdmin) {
                return new StringBuilder().append(applicationAdmin.getAdminEmailId()).toString();
            }
        };
    }

	public Converter<Long, ApplicationAdmin> getIdToApplicationAdminConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.store.satring.dos.ApplicationAdmin>() {
            public com.store.satring.dos.ApplicationAdmin convert(java.lang.Long id) {
                return ApplicationAdmin.findApplicationAdmin(id);
            }
        };
    }

	public Converter<String, ApplicationAdmin> getStringToApplicationAdminConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.store.satring.dos.ApplicationAdmin>() {
            public com.store.satring.dos.ApplicationAdmin convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), ApplicationAdmin.class);
            }
        };
    }
	public Converter<Customer, String> getCustomerToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.store.satring.dos.Customer, java.lang.String>() {
            public String convert(Customer customer) {
                return new StringBuilder().append(customer.getName()).append('-').append(customer.getAddress()).toString();
            }
        };
    }

	public Converter<Long, Customer> getIdToCustomerConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.store.satring.dos.Customer>() {
            public com.store.satring.dos.Customer convert(java.lang.Long id) {
                return Customer.findCustomer(id);
            }
        };
    }

	public Converter<String, Customer> getStringToCustomerConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.store.satring.dos.Customer>() {
            public com.store.satring.dos.Customer convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Customer.class);
            }
        };
    }
	
	public Converter<GLReport, String> getGLReportToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.store.satring.dos.GLReport, java.lang.String>() {
            public String convert(GLReport gLReport) {
                return new StringBuilder().append(gLReport.getGLDateFrom()).append(' ').append(gLReport.getGLDateTo()).toString();
            }
        };
    }

	public Converter<String, GLReport> getStringToGLReportConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.store.satring.dos.GLReport>() {
            public com.store.satring.dos.GLReport convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), GLReport.class);
            }
        };
    }

	public Converter<GeneralLedger, String> getGeneralLedgerToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.store.satring.dos.GeneralLedger, java.lang.String>() {
            public String convert(GeneralLedger generalLedger) {
                return new StringBuilder().append(generalLedger.getGlNo()).append('-').append(generalLedger.getInvoice().getInvoiceNo()).append('-').append(generalLedger.getInvoice().getCustomer().getName()).toString();
            }
        };
    }

	public Converter<Long, GeneralLedger> getIdToGeneralLedgerConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.store.satring.dos.GeneralLedger>() {
            public com.store.satring.dos.GeneralLedger convert(java.lang.Long id) {
                return GeneralLedger.findGeneralLedger(id);
            }
        };
    }

	public Converter<String, GeneralLedger> getStringToGeneralLedgerConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.store.satring.dos.GeneralLedger>() {
            public com.store.satring.dos.GeneralLedger convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), GeneralLedger.class);
            }
        };
    }

	public Converter<GeneralLedgerDetail, String> getGeneralLedgerDetailToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.store.satring.dos.GeneralLedgerDetail, java.lang.String>() {
            public String convert(GeneralLedgerDetail generalLedgerDetail) {
                return new StringBuilder().append(generalLedgerDetail.getAmount()).append(' ').append(generalLedgerDetail.getReceivedOn()).append(' ').append(generalLedgerDetail.getDescription()).toString();
            }
        };
    }

	public Converter<Long, GeneralLedgerDetail> getIdToGeneralLedgerDetailConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.store.satring.dos.GeneralLedgerDetail>() {
            public com.store.satring.dos.GeneralLedgerDetail convert(java.lang.Long id) {
                return GeneralLedgerDetail.findGeneralLedgerDetail(id);
            }
        };
    }

	public Converter<String, GeneralLedgerDetail> getStringToGeneralLedgerDetailConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.store.satring.dos.GeneralLedgerDetail>() {
            public com.store.satring.dos.GeneralLedgerDetail convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), GeneralLedgerDetail.class);
            }
        };
    }

	public Converter<Invoice, String> getInvoiceToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.store.satring.dos.Invoice, java.lang.String>() {
            public String convert(Invoice invoice) {
//                return new StringBuilder().append(invoice.getInvoiceNo()).append(' ').append(invoice.getInvoiceDate()).append(' ').append(invoice.getSiteFor()).append(' ').append(invoice.getDescription()).toString();
                return new StringBuilder().append(invoice.getInvoiceNo()).append('-').append(invoice.getCustomer().getName()).toString();
            }
        };
    }

	public Converter<Long, Invoice> getIdToInvoiceConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.store.satring.dos.Invoice>() {
            public com.store.satring.dos.Invoice convert(java.lang.Long id) {
                return Invoice.findInvoice(id);
            }
        };
    }

	public Converter<String, Invoice> getStringToInvoiceConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.store.satring.dos.Invoice>() {
            public com.store.satring.dos.Invoice convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Invoice.class);
            }
        };
    }

	public Converter<Item, String> getItemToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.store.satring.dos.Item, java.lang.String>() {
            public String convert(Item item) {
              return new StringBuilder().append(item.getItemType().getName()).append(" - ").append(item.getName()).toString();
            }
        };
    }

	public Converter<Long, Item> getIdToItemConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.store.satring.dos.Item>() {
            public com.store.satring.dos.Item convert(java.lang.Long id) {
                return Item.findItem(id);
            }
        };
    }

	public Converter<String, Item> getStringToItemConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.store.satring.dos.Item>() {
            public com.store.satring.dos.Item convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Item.class);
            }
        };
    }

	public Converter<ItemBalanceDetail, String> getItemBalanceDetailToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.store.satring.dos.ItemBalanceDetail, java.lang.String>() {
            public String convert(ItemBalanceDetail itemBalanceDetail) {
                return new StringBuilder().append(itemBalanceDetail.getQuantity()).toString();
            }
        };
    }

	public Converter<Long, ItemBalanceDetail> getIdToItemBalanceDetailConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.store.satring.dos.ItemBalanceDetail>() {
            public com.store.satring.dos.ItemBalanceDetail convert(java.lang.Long id) {
                return ItemBalanceDetail.findItemBalanceDetail(id);
            }
        };
    }

	public Converter<String, ItemBalanceDetail> getStringToItemBalanceDetailConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.store.satring.dos.ItemBalanceDetail>() {
            public com.store.satring.dos.ItemBalanceDetail convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), ItemBalanceDetail.class);
            }
        };
    }

	public Converter<ItemDetail, String> getItemDetailToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.store.satring.dos.ItemDetail, java.lang.String>() {
            public String convert(ItemDetail itemDetail) {
                return new StringBuilder().append(itemDetail.getQuantity()).append(' ').append(itemDetail.getRentedOn()).append(' ').append(itemDetail.getDescription()).toString();
            }
        };
    }

	public Converter<Long, ItemDetail> getIdToItemDetailConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.store.satring.dos.ItemDetail>() {
            public com.store.satring.dos.ItemDetail convert(java.lang.Long id) {
                return ItemDetail.findItemDetail(id);
            }
        };
    }

	public Converter<String, ItemDetail> getStringToItemDetailConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.store.satring.dos.ItemDetail>() {
            public com.store.satring.dos.ItemDetail convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), ItemDetail.class);
            }
        };
    }

	public Converter<ItemReturnDetail, String> getItemReturnDetailToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.store.satring.dos.ItemReturnDetail, java.lang.String>() {
            public String convert(ItemReturnDetail itemReturnDetail) {
                return new StringBuilder().append(itemReturnDetail.getQuantity()).append(' ').append(itemReturnDetail.getReturnedOn()).append(' ').append(itemReturnDetail.getDescription()).toString();
            }
        };
    }

	public Converter<Long, ItemReturnDetail> getIdToItemReturnDetailConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.store.satring.dos.ItemReturnDetail>() {
            public com.store.satring.dos.ItemReturnDetail convert(java.lang.Long id) {
                return ItemReturnDetail.findItemReturnDetail(id);
            }
        };
    }

	public Converter<String, ItemReturnDetail> getStringToItemReturnDetailConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.store.satring.dos.ItemReturnDetail>() {
            public com.store.satring.dos.ItemReturnDetail convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), ItemReturnDetail.class);
            }
        };
    }

	public Converter<ItemType, String> getItemTypeToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.store.satring.dos.ItemType, java.lang.String>() {
            public String convert(ItemType itemType) {
                return new StringBuilder().append(itemType.getName()).toString();
            }
        };
    }

	public Converter<Long, ItemType> getIdToItemTypeConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.store.satring.dos.ItemType>() {
            public com.store.satring.dos.ItemType convert(java.lang.Long id) {
                return ItemType.findItemType(id);
            }
        };
    }

	public Converter<String, ItemType> getStringToItemTypeConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.store.satring.dos.ItemType>() {
            public com.store.satring.dos.ItemType convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), ItemType.class);
            }
        };
    }
	
	public Converter<ItemReport, String> getItemReportToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.store.satring.dos.ItemReport, java.lang.String>() {
            public String convert(ItemReport itemReport) {
                return new StringBuilder().append(itemReport.getInvoiceDateFrom()).append(' ').append(itemReport.getInvoiceDateTo()).toString();
            }
        };
    }

	public Converter<String, ItemReport> getStringToItemReportConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.store.satring.dos.ItemReport>() {
            public com.store.satring.dos.ItemReport convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), ItemReport.class);
            }
        };
    }
	public Converter<Long, Authorities> getIdToAuthoritiesConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.store.satring.dos.aa.Authorities>() {
            public com.store.satring.dos.aa.Authorities convert(java.lang.Long id) {
                return Authorities.findAuthorities(id);
            }
        };
    }

	public Converter<String, Authorities> getStringToAuthoritiesConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.store.satring.dos.aa.Authorities>() {
            public com.store.satring.dos.aa.Authorities convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Authorities.class);
            }
        };
    }

	public Converter<GroupAuthorities, String> getGroupAuthoritiesToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.store.satring.dos.aa.GroupAuthorities, java.lang.String>() {
            public String convert(GroupAuthorities groupAuthorities) {
                return new StringBuilder().append(groupAuthorities.getAuthority()).toString();
            }
        };
    }

	public Converter<Long, GroupAuthorities> getIdToGroupAuthoritiesConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.store.satring.dos.aa.GroupAuthorities>() {
            public com.store.satring.dos.aa.GroupAuthorities convert(java.lang.Long id) {
                return GroupAuthorities.findGroupAuthorities(id);
            }
        };
    }

	public Converter<String, GroupAuthorities> getStringToGroupAuthoritiesConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.store.satring.dos.aa.GroupAuthorities>() {
            public com.store.satring.dos.aa.GroupAuthorities convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), GroupAuthorities.class);
            }
        };
    }

	public Converter<GroupMembers, String> getGroupMembersToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.store.satring.dos.aa.GroupMembers, java.lang.String>() {
            public String convert(GroupMembers groupMembers) {
                return new StringBuilder().append(groupMembers.getUsername()).toString();
            }
        };
    }

	public Converter<Long, GroupMembers> getIdToGroupMembersConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.store.satring.dos.aa.GroupMembers>() {
            public com.store.satring.dos.aa.GroupMembers convert(java.lang.Long id) {
                return GroupMembers.findGroupMembers(id);
            }
        };
    }

	public Converter<String, GroupMembers> getStringToGroupMembersConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.store.satring.dos.aa.GroupMembers>() {
            public com.store.satring.dos.aa.GroupMembers convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), GroupMembers.class);
            }
        };
    }

	public Converter<Groups, String> getGroupsToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.store.satring.dos.aa.Groups, java.lang.String>() {
            public String convert(Groups groups) {
                return new StringBuilder().append(groups.getGroupName()).toString();
            }
        };
    }

	public Converter<Long, Groups> getIdToGroupsConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.store.satring.dos.aa.Groups>() {
            public com.store.satring.dos.aa.Groups convert(java.lang.Long id) {
                return Groups.findGroups(id);
            }
        };
    }

	public Converter<String, Groups> getStringToGroupsConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.store.satring.dos.aa.Groups>() {
            public com.store.satring.dos.aa.Groups convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Groups.class);
            }
        };
    }

	public Converter<Users, String> getUsersToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.store.satring.dos.aa.Users, java.lang.String>() {
            public String convert(Users users) {
                return new StringBuilder().append(users.getLoginId()).append(' ').append(users.getName()).append(' ').append(users.getEmailId()).append(' ').append(users.getMobileNo()).toString();
            }
        };
    }

	public Converter<Long, Users> getIdToUsersConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.store.satring.dos.aa.Users>() {
            public com.store.satring.dos.aa.Users convert(java.lang.Long id) {
                return Users.findUsers(id);
            }
        };
    }

	public Converter<String, Users> getStringToUsersConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.store.satring.dos.aa.Users>() {
            public com.store.satring.dos.aa.Users convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Users.class);
            }
        };
    }

	public void installLabelConverters(FormatterRegistry registry) {
        registry.addConverter(getCustomerToStringConverter());
        registry.addConverter(getIdToCustomerConverter());
        registry.addConverter(getStringToCustomerConverter());
        registry.addConverter(getInvoiceToStringConverter());
        registry.addConverter(getIdToInvoiceConverter());
        registry.addConverter(getStringToInvoiceConverter());
        registry.addConverter(getItemToStringConverter());
        registry.addConverter(getIdToItemConverter());
        registry.addConverter(getStringToItemConverter());
        registry.addConverter(getItemBalanceDetailToStringConverter());
        registry.addConverter(getIdToItemBalanceDetailConverter());
        registry.addConverter(getStringToItemBalanceDetailConverter());
        registry.addConverter(getItemDetailToStringConverter());
        registry.addConverter(getIdToItemDetailConverter());
        registry.addConverter(getStringToItemDetailConverter());
        registry.addConverter(getItemReturnDetailToStringConverter());
        registry.addConverter(getIdToItemReturnDetailConverter());
        registry.addConverter(getStringToItemReturnDetailConverter());
        registry.addConverter(getItemTypeToStringConverter());
        registry.addConverter(getIdToItemTypeConverter());
        registry.addConverter(getStringToItemTypeConverter());
        registry.addConverter(getAuthoritiesToStringConverter());
        registry.addConverter(getIdToAuthoritiesConverter());
        registry.addConverter(getStringToAuthoritiesConverter());
        registry.addConverter(getGroupAuthoritiesToStringConverter());
        registry.addConverter(getIdToGroupAuthoritiesConverter());
        registry.addConverter(getStringToGroupAuthoritiesConverter());
        registry.addConverter(getGroupMembersToStringConverter());
        registry.addConverter(getIdToGroupMembersConverter());
        registry.addConverter(getStringToGroupMembersConverter());
        registry.addConverter(getGroupsToStringConverter());
        registry.addConverter(getIdToGroupsConverter());
        registry.addConverter(getStringToGroupsConverter());
        registry.addConverter(getUsersToStringConverter());
        registry.addConverter(getIdToUsersConverter());
        registry.addConverter(getStringToUsersConverter());
        registry.addConverter(getApplicationAdminToStringConverter());
        registry.addConverter(getIdToApplicationAdminConverter());
        registry.addConverter(getStringToApplicationAdminConverter());
        registry.addConverter(getGLReportToStringConverter());
        registry.addConverter(getStringToGLReportConverter());
        registry.addConverter(getGeneralLedgerToStringConverter());
        registry.addConverter(getIdToGeneralLedgerConverter());
        registry.addConverter(getStringToGeneralLedgerConverter());
        registry.addConverter(getGeneralLedgerDetailToStringConverter());
        registry.addConverter(getIdToGeneralLedgerDetailConverter());
        registry.addConverter(getStringToGeneralLedgerDetailConverter());
        registry.addConverter(getItemReportToStringConverter());
        registry.addConverter(getStringToItemReportConverter());


    }

	public void afterPropertiesSet() {
        super.afterPropertiesSet();
        installLabelConverters(getObject());
    }
}
